Imports Microsoft.VisualBasic

Namespace $YourCompany$.Modules.$safeprojectname$

    Public Class SilverlightPortalModuleBase
        Inherits AjaxPortalModuleBase

        Private Const DEFAULT_OBJECTWIDTH = 320
        Private Const DEFAULT_OBJECTHEIGHT = 200
        Private Const DEFAULT_XAMLFILE = "media.xaml"

        Public Property ObjectWidth() As Integer
            Get
                If String.IsNullOrEmpty(Settings("ObjectWidth")) Then
                    Return DEFAULT_OBJECTWIDTH
                Else
                    Return CInt(Settings("ObjectWidth"))
                End If
            End Get
            Set(ByVal value As Integer)
                Settings("ObjectWidth") = value
            End Set
        End Property

        Public Property ObjectHeight() As Integer
            Get
                If String.IsNullOrEmpty(Settings("ObjectHeight")) Then
                    Return DEFAULT_OBJECTHEIGHT
                Else
                    Return CInt(Settings("ObjectHeight"))
                End If
            End Get
            Set(ByVal value As Integer)
                Settings("ObjectHeight") = value
            End Set
        End Property

        Public Property XAMLFile() As String
            Get
                If String.IsNullOrEmpty(Settings("XAMLFile")) Then
                    Return DEFAULT_XAMLFILE
                Else
                    Return CStr(Settings("XAMLFile"))
                End If
            End Get
            Set(ByVal value As String)
                Settings("XAMLFile") = value
            End Set
        End Property


#Region "AjaxPortalModuleBase Events"
        Protected Sub AjaxPortalModuleBase_AddScriptComponentDescriptors(ByVal Descriptor As ScriptComponentDescriptor) Handles MyBase.AddScriptComponentDescriptors

            Descriptor.AddScriptProperty("xamlPath", String.Format("'{0}'", Me.ModulePath & "assets/"))
            Descriptor.AddScriptProperty("xamlFile", String.Format("'{0}'", Me.XAMLFile))

            If ObjectHeight <> DEFAULT_OBJECTHEIGHT Then
                Descriptor.AddScriptProperty("height", String.Format("'{0}'", ObjectHeight.ToString()))
            End If
            If ObjectHeight <> DEFAULT_OBJECTWIDTH Then
                Descriptor.AddScriptProperty("width", String.Format("'{0}'", ObjectWidth.ToString()))
            End If

        End Sub

        '-------------------------------------------------------------------------------------------------------------
        '- This is where your client-side javascript that uses the MS AJAX framework needs to be registered
        '- Adding the reference here ensures that the MS AJAX script is run before our script which uses things like Type.registerNamespace run
        '-------------------------------------------------------------------------------------------------------------
        Protected Sub AjaxPortalModuleBase_AddScriptReferences(ByVal References As List(Of ScriptReference)) Handles MyBase.AddScriptReferences
            References.Add(New System.Web.UI.ScriptReference(Me.ModulePath & "silverlight.js"))
        End Sub

#End Region


    End Class
End Namespace